<%@page import="bean.BoardDTO"%>
<%@page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy"%>
<%@page import="java.util.Enumeration"%>
<%@page import="com.oreilly.servlet.MultipartRequest"%>
<%@page import="bean.BoardVO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>input_result.jsp</title>
<link rel="stylesheet" href="../css/boards.css"/>
<script type="text/javascript" src="../js/boards.js"></script>
</head>
<body>
	<%
	int size = 1024*1024*10;
	String saveDir = "C:/Users/jhta/Documents/javaworkspace/web_1406/WebContent/uploadFile";
	String oriFile = "";
	String sysFile = "";
	MultipartRequest mr = null;
	
	try{
		mr = new MultipartRequest(request, saveDir, size, "utf-8", new DefaultFileRenamePolicy());
		
		Enumeration files = mr.getFileNames();
		
		String tmpFile = (String)files.nextElement();
		oriFile = mr.getOriginalFileName(tmpFile);
		sysFile = mr.getFilesystemName(tmpFile);
		
	}catch(Exception e){
		e.printStackTrace();
	}
	%>
	<h1>게시판 입력 결과</h1><hr/>
	<%
		BoardDTO dto = new BoardDTO();
		BoardVO vo = new BoardVO(request);
	
		vo.setSubject(mr.getParameter("subject"));
		vo.setContent(mr.getParameter("content"));
		vo.setMid(mr.getParameter("mid"));
		vo.setPwd(mr.getParameter("pwd"));
		vo.setTag(mr.getParameter("tag"));
		if(mr.getParameter("attfile") != null){
			vo.setAttfile(sysFile);
		}else{
			vo.setAttfile("파일없음");
		}
		dto.setVo(vo);
		dto.insert();
	%>
	<div style="font-weight: bold; font-family: 돋움;">아이디: <%=mr.getParameter("mid") %></div>
	<div style="font-weight: bold; font-family: 돋움;">비밀번호: <%=mr.getParameter("content") %></div>
	<div style="font-weight: bold; font-family: 돋움;">제목: <%=mr.getParameter("mid") %></div>
	<div style="font-weight: bold; font-family: 돋움;">내용: <%=mr.getParameter("pwd") %></div>
	<div style="font-weight: bold; font-family: 돋움;">첨부파일: <%=mr.getParameter("attfile") %></div>
	<div style="font-weight: bold; font-family: 돋움;">태그: <%=mr.getParameter("tag") %></div>
	<h2>글 등록이 완료되었습니다.</h2>
	<input type="button" id="btnList" value="목록"/>
</body>
<script type="text/javascript">inputInit();</script>
</html>